package cn.org.timespace.ons.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.org.timespace.ons.inside.mina.server.MinaESInServer;
import cn.org.timespace.ons.socket.mina.server.MinaESCardServer;
import cn.org.timespace.plat.socket.mina.server.MinaESPlatServer;


public class InitiationSystemLoaderListener implements ServletContextListener {

	private final static Log log = LogFactory.getLog(InitiationSystemLoaderListener.class);
	
	/* 清理数据
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent event) {
		// TODO Auto-generated method stub

	}

	/* 初始化数据
	 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent event) {

		try {
			log.debug("开始启动Socket Server 监听");
			MinaESCardServer.run();
			log.debug("成功启动Socket Server 监听");
			
			log.debug("开始启动Socket In 监听");
			MinaESInServer.run();
            log.debug("成功启动Socket In 监听");
            
            log.debug("开始启动Socket plat 监听");
			MinaESPlatServer.run();
            log.debug("成功启动Socket plat 监听");
		} catch (Exception e) {
			log.error("初始化数据出现异常：" + e);
			e.printStackTrace();
		}

	}

}
